package com.cordwood.helper.localdb;

import lombok.val;

import javax.net.ServerSocketFactory;
import java.io.IOException;
import java.net.InetAddress;

class SocketUtils {
    static boolean isPortAvailable(int port) {
        try (val ignored = ServerSocketFactory.getDefault().createServerSocket(port, 1, InetAddress.getByName("localhost"))) {
            return true;
        } catch (IOException e) {
            return false;
        }

    }
}
